<%@ page import="entity.Operator" %>
<%@ page import="service.CharacterService" %>
<%@ page import="entity.Modular" %>
<%@ page import="java.util.List" %>
<%@ page import="service.PermissionService" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: zhouya
  Date: 2019/6/19/0019
  Time: 21:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>后台首页</title>
    <link type="text/css" rel="stylesheet" href="../css/admin/index.css"/>
    <link type="text/js" rel="stylesheet" href="../js/index.js"/>
    <%
        Operator operator = (Operator) request.getSession().getAttribute("loginOperator");
        String character = new CharacterService().getCharacterNameById(operator.getCharacter());
        List<Modular> modulars = new PermissionService().modularsByCharactersID(operator.getCharacter());
        List<Integer> permissions = new ArrayList<>();
        for(Modular m : modulars)
            permissions.add(m.getModularId());

    %>
    <script language="javascript">
        //从服务器上获取初始时间
        var currentDate = new Date(<%=new java.util.Date().getTime()%>);
        function run()
        {
            currentDate.setSeconds(currentDate.getSeconds()+1);
            document.getElementById("dt").innerHTML = currentDate.toLocaleString();
        }
        window.setInterval("run();", 1000);
    </script>
</head>
<body>
    <div class="admin_index">
        <div class="admin_index_top">
            <div style="padding-top: 1%">
            <span style="margin-left: 6%;font-size: 20px;">网站后台管理系统</span>
            <span style="margin-left: 70%">|<a href="passwordChange.jsp">修改密码</a>|<a href="../welcome.jsp">退出</a>|</span>
            </div>
            <div style="padding-top: 4%">
                <span style="margin-left: 6%">欢迎您，<%=operator.getName()%>&emsp;<%=character%></span>
                <span style="margin-left: 68%">
                    <img src="../image/shouye.png" onclick="window.location='../welcome.jsp'" style="width: 4%;height: 20%">
                    <img src="../image/return_syj.png" onclick="window.location='../welcome.jsp'" style="width: 4%;height: 20%">
                </span>
            </div>
        </div>
        <div class="content">
        <div id="admin_left_title">
            <img src="../image/clock.png" style="width: 25px ;height: 25px">
            <span id="dt" style="font-size: 14px"></span><br><br>

            <details open><summary>网站内容管理</summary></details>
            <dl class="second">
                <%if(permissions.contains(1)){%><dd><a href="message.jsp" target="content">留言管理</a></dd><%}%>
                <%if(permissions.contains(2)){%><dd><a href="passage.jsp" target="content">文章管理</a></dd><%}%>
                <%if(permissions.contains(3)){%><dd><a href="ReviewPassageServlet?page=1" target="content">审核文章</a></dd><%}%>
                <%if(permissions.contains(4)){%><dd><a href="AdminFieldServlet" target="content">栏目管理</a></dd><%}%>
            </dl>

            <details open><summary>系统设置</summary></details>
            <dl class="second">
                <%if(permissions.contains(5)){%><dd><a href="AdminCharactersServlet?cp=permission" target="content">权限管理</a></dd><%}%>
                <%if(permissions.contains(6)){%><dd><a href="AdminCharactersServlet?cp=modular" target="content">模块管理</a></dd><%}%>
                <%if(permissions.contains(7)){%><dd><a href="CharactersDistributionServlet?page=1" target="content">角色分配</a></dd><%}%>
                <%if(permissions.contains(8)){%><dd><a href="AdminOperatorsServlet?page=1"  target="content">人员管理</a></dd><%}%>
                <%if(permissions.contains(9)){%><dd><a href="AdminCharactersServlet?cp=characters" target="content">角色管理</a></dd><%}%>
                <%if(permissions.contains(10)){%><dd><a target="content">默认功能设置</a></dd><%}%>
                <%if(permissions.contains(11)){%><dd><a target="content">首页信息设置</a></dd><%}%>
                <%if(permissions.contains(12)){%><dd><a target="content">码表管理</a></dd><%}%>
            </dl>

        </div>
            <div>
                <iframe id="admin_right_content" name="content" frameborder="0"></iframe>
            </div>
        </div>
        <div class="admin_bottom">

        </div>
    </div>
</body>
</html>